public class Offer63 {
    public int maxProfit(int[] prices) {
        int dp = 0;
        int low = Integer.MAX_VALUE;
        for (int i = 0; i < prices.length; i++) {
            low = Math.min(low,prices[i]);
            dp = Math.max(dp,prices[i]-low);
        }
        return dp;
    }
}
